<template>
  <view class="site-wraps">
    <view class="swiper-box"
      ><u-swiper
        class="site-swiper"
        :list="bannerArr"
        indicator
        :indicator-mode="'number'"
        :indicator-color="'#ffffff'"
        :indicator-active-color="'#007aff'"
      ></u-swiper>
    </view>
    <view class="total">今日管内人数：200人</view>
    <!-- 场馆介绍 -->
    <view class="city-info">
      <view class="info-top">
        <view class="city-title">
          <image
            src="https://ya30images.hbwlife.com/wxmp/logo-yongan30.png"
            mode=""
          ></image>
          <view class="txt">泳安30</view>
        </view>
        <view class="tag-wrap">
          <view class="card-box">
            <view class="every">体育游泳馆</view>
            <view class="every">休闲娱乐</view>
            <view class="every">深水区</view>
            <view class="every">浅水区</view>
          </view>
        </view>
        <!-- <view class="site-toggle">
          <image class="toggle-btn" src="@/static/img/toggle.png"></image>
          <view class="txt">切换场馆</view>
        </view> -->
      </view>
      <view class="info-bottom">
        <view class="address">北京金泳安科技有限公司</view>
        <div class="right">
          <image
            class="nav"
            @click="goToLocation"
            src="@/static/img/nav.png"
          ></image>
          <image
            class="phone"
            @click="callPhoneNumber()"
            src="@/static/img/phone.png"
          ></image>
        </div>
      </view>
    </view>
    <!--  -->
    <view class="yellow">团购购票</view>

    <view class="hot-wrap">
      <div class="title-wrap">
        <view class="title-line"></view>
        <div class="title">热门活动</div>
      </div>

      <view class="item-wrap">
        <view class="item">
          <view class="txt1">最新活动</view>
          <view class="txt2">查看</view>
        </view>
        <view class="item"
          ><view class="txt1">热门场馆</view>
          <view class="txt2">查看</view></view
        >
        <view class="item"
          ><view class="txt1">卡课推荐</view>
          <view class="txt2">查看</view></view
        >
      </view>
    </view>
  </view>
</template>

<script>
import { request, requestData } from '@/utils/http.js'

export default {
  data() {
    return {
      bannerArr: [],
      latitude: '',
      longitude: '',
      name: '',
      address: '',
    }
  },
  async onShow(options) {
    await this.$onLaunched
    await this.initSiteInfo()
  },
  methods: {
    //banner img
    initSiteInfo(str) {
      request('/common/site/info', {
        site_code: '17001',
        with_images: 1,
      })
        .then((res) => {
          this.siteInfo = res.datas
          let bannerPic = res.datas.images
          this.bannerArr.push(
            bannerPic.logo1,
            bannerPic.logo2,
            bannerPic.logo3,
            bannerPic.logo4,
            bannerPic.logo5,
            bannerPic.logo6,
            bannerPic.logo7,
            bannerPic.logo8,
            bannerPic.logo9
          )
          this.site_code = res.datas.images.site_code
        })
        .catch((err) => {
          console.log(err)
        })
    },
    goToLocation() {
      uni.openLocation({
        latitude: this.siteInfo.latitude,
        longitude: this.siteInfo.longitude,
        name: this.siteInfo.site_name,
        address: this.siteInfo.city + '市' + this.siteInfo.address,
        success() {
          console.log('导航成功')
        },
        fail(err) {
          console.error('导航失败', err)
          uni.showToast({
            title: '导航失败！',
            icon: 'none',
          })
        },
      })
    },
    callPhoneNumber() {
      uni.makePhoneCall({
        phoneNumber: this.siteInfo.phone,
        success: () => {
          console.log('拨打成功！')
        },
        fail: () => {
          console.error('拨打失败！')
        },
      })
    },
  },
}
</script>

<style lang="scss" scoped>
.site-wraps {
  width: 100%;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
  background: #222c41;
  padding-top: 0;
  margin-top: 0;
}

.swiper-box {
  width: 94%;
  height: 260rpx;
  margin: 0 auto;
  margin-top: 20rpx;
}

/* 更改u-swiper样式 */
::v-deep .u-swiper {
  height: 100% !important;
}

::v-deep .u-swiper__wrapper.data-v-6b019429 {
  height: 100% !important;
}

::v-deep .u-swiper__wrapper__item__wrapper__image.data-v-6b019429 {
  height: 100% !important;
}

::v-deep .u-swiper__indicator data-v-6b019429 {
  bottom: 40rpx !important;
}

::v-deep .u-swiper__indicator-dot {
  width: 58rpx !important;
  height: 58rpx !important;
}

.total {
  color: #eec07e;
  height: 60rpx;
  line-height: 60rpx;
  margin-top: 20rpx;
  padding: 0 20rpx;
  font-size: 28rpx;
}

/* info */
.city-info {
  width: 96%;
  height: auto;
  margin: 0 auto;
  margin-top: 20rpx;
  padding: 0 20rpx;
  box-sizing: border-box;
}

.city-info .info-top {
  display: flex;
  justify-content: center;
  flex-flow: column;
  align-items: flex-start;
  height: 160rpx;
  line-height: 1;
  background: #283145;
  border-radius: 20rpx 20rpx 0 0;
}

.city-title {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 0 20rpx;
}

.city-title image {
  width: 80rpx;
  height: 80rpx;
  margin-right: 15rpx;
}

.city-title .txt {
  color: #fff;
}

// .site-toggle {
//   padding: 10rpx;
//   border-radius: 15rpx 0 0 15rpx;
//   position: absolute;
//   right: 0;
//   width: auto;
//   height: 40rpx;
//   display: flex;
//   justify-content: flex-start;
//   align-items: center;
//   font-size: 22rpx;
//   // background: #f5f2f2;
//   color: #6e6d6d;
// }
// .site-toggle .toggle-btn {
//   width: 36rpx;
//   height: 36rpx;
//   margin-right: 15rpx;
// }
.city-info .info-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100rpx;
  background: #2c3448;
  padding: 0 20rpx;
  box-sizing: border-box;
  border-radius: 0 0 20rpx 20rpx;
}

.info-bottom .address {
  font-size: 28rpx;
  color: #fff;
}

.info-bottom .right {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.info-bottom .right image {
  width: 40rpx;
  height: 40rpx;
  padding: 0 30rpx;
}

.info-bottom .right .nav {
  border-right: 1px dashed #f6c782;
}

.info-bottom .right .phone {
  padding-right: 0;
}

/*  */
.tag-wrap {
  box-sizing: border-box;
  padding: 20rpx;
  font-size: 28rpx;
}

.card-box {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.every {
  background: #80a1e0;
  margin-right: 20rpx;
  padding: 8rpx;
  border-radius: 10rpx;
  font-size: 24rpx;
  color: #09388a;
}

/*  */
.yellow {
  background: #f6c782;
  width: 94%;
  height: 80rpx;
  margin: 0 auto;
  margin-top: 30rpx;
  border-radius: 15rpx;
  line-height: 80rpx;
  color: #28344a;
  display: flex;
  justify-content: center;
  align-items: center;
}
.hot-wrap {
  width: 94%;
  height: auto;
  margin: 0 auto;
  margin-top: 40rpx;
  background: #293247;
  padding: 20rpx;
  box-sizing: border-box;
  border-radius: 20rpx;
  padding-bottom: 50rpx;
}

.hot-wrap .title-wrap {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.hot-wrap .title {
  width: 100%;
  height: 80rpx;
  line-height: 80rpx;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  box-sizing: border-box;
  color: #fff;
}
.hot-wrap .title-line {
  width: 6rpx;
  height: 30rpx;
  background-color: #fff;
  border-radius: 2px;
  box-sizing: border-box;
  margin-right: 20rpx;
}
.hot-wrap .item-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 260rpx;
  margin: 0 auto;
  margin-top: 20rpx;
}
.hot-wrap .item {
  width: 32%;
  height: 100%;
  border-radius: 20rpx;
  display: flex;
  flex-flow: column;
  justify-content: center;
  align-items: center;

  background: rgba(0, 0, 0, 0.2);
}
.hot-wrap .item .txt1 {
  color: #fff;
  font-size: 28rpx;
}
.hot-wrap .item .txt2 {
  color: $global-color-golden;
  font-size: 24rpx;
  margin-top: 20rpx;
}

/*  */
</style>
